#define _CRT_SECURE_NO_WARNINGS 1
#pragma warning(disable:6031)

#include<stdio.h>

struct stu
{
	char name[20];
	float age;
};

int compar_arr_by_age(const void* p1, const void* p2)
{
	//return (((struct stu*)p1)->age - ((struct stu*)p2)->age);
	return ((struct stu*)p1)->age > ((struct stu*)p2)->age ? 1 : -1;
}

int compar_arr_by_name(const void* p1, const void* p2)
{
	//return (((struct stu*)p1)->age - ((struct stu*)p2)->age);
	return strcmp(((struct stu*)p2)->name, ((struct stu*)p1)->name);
}

int main()
{
	struct stu a = { "lihua",99 };
	struct stu arr[] = { {"zhangsan",78.9},{"lisi",66.9},{"wangwu",16.3} };
	int num = sizeof(arr) / sizeof(arr[0]);
	qsort(arr, num, sizeof(arr[0]), compar_arr_by_age);
	//qsort(arr, num, sizeof(arr[0]), compar_arr_by_name);
	return 0;
}